package com.example.controller;

import com.example.entity.User;
import com.example.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * com.example.controller.UserController
 *
 * @author ZRS
 * @version V1.0
 * @since 2025/10/30 22:35
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    UserService userService;


    @GetMapping("/detail/{id}")
    public User getById(@PathVariable("id") Integer id) {
        return userService.getUserById(id);
    }

    @PostMapping("/saveUser")
    public Map<String, Object> saveUser(@RequestBody User user) {
        boolean b = userService.saveUser(user);
        Map<String, Object> data = new HashMap<>();
        data.put("code", "200");
        return data;
    }

}
